package com.yanqu.road.server.cmd.activity.xiuxian;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.XiuXianProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.xiuxian.XiuXianModule;
import com.yanqu.road.server.protocol.Protocol;


@Cmd(code = Protocol.S_XIU_XIAN_TRIPOD_DRAW, desc = "凡人虚空鼎抽取法宝")
public class XiuxianTripodDrawCmd extends AbstractCommand {

	private Integer activityId;

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		XiuXianProto.XiuXianTripodDrawReqMsg reqMsg = XiuXianProto.XiuXianTripodDrawReqMsg.parseFrom(packet.getBytes());
		activityId = reqMsg.getActivityId();
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		ret = player.getModule(XiuXianModule.class).tripodDraw(activityId);
	}

	@Override
	public void sendData(GamePlayer player) {
		if(ret != 0){
			XiuXianProto.XiuXianTripodDrawRespMsg.Builder builder = XiuXianProto.XiuXianTripodDrawRespMsg.newBuilder();
			builder.setRet(ret);
			player.sendPacket(Protocol.U_XIU_XIAN_TRIPOD_DRAW, builder);
		}
	}
}